#pragma once

// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the VIAFIRMACLIENT_EXPORTS
// symbol defined on the command line. This symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// VIAFIRMACLIENT_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef VIAFIRMACLIENT_EXPORTS
#define VIAFIRMACLIENT_API __declspec(dllexport)
#else
#define VIAFIRMACLIENT_API __declspec(dllimport)
#endif

#include <string>


#define VIAFIRMA_CLIENT_VERSION "C++:3.0.4"


/**
XMLSIG_ENVELOPING,
	XADES_EPES_ENVELOPED,
	CMS,
	PDF_PKCS7,
	XADES_T_ENVELOPED,
	XADES_XL_ENVELOPED
	*/

#define TYPE_FILE_BINARRY "BINARY"
#define TYPE_FILE_HASH_BINARRY "HASH"


/**
XMLSIG_ENVELOPING,
	XADES_EPES_ENVELOPED,
	CMS,
	PDF_PKCS7,
	XADES_T_ENVELOPED,
	XADES_XL_ENVELOPED
	*/

#define TYPE_FORMAT_SIGN_BINARRY "CMS"


class VIAFIRMACLIENT_API SignedDocument{
public:
	std::string id;
	const char * data;
	int dataLen;
	std::string rsaKeySize;
	const char * X509;
	int X509Len;
	std::string serialNumber;
	std::string issuerDN;
		
~SignedDocument(void);
};


class VIAFIRMACLIENT_API viafirmaClient 

{
public:
	viafirmaClient(std::string);
	~viafirmaClient(void);

	std::string ping(std::string msg);

	std::string signByServer(std::string nameDocument, unsigned char * dataToSign, int dataSize,std::string alias, std::string password,std::string tileFormat,std::string formatSign);

	/**
	* Sign document.
	* Compute sha1 and send to server only sha1
	*/
	std::string signByServerWithSha1(std::string nameDocument, unsigned char * dataToSign,int dataSize, std::string alias, std::string password,std::string formatSign);

	/**
	* Validaten document.
	* Compute sha1 and send to server only sha1
	*/
	bool viafirmaClient::validateWithSha1(unsigned char * dataSigned,int dataSize,unsigned char * signInfo,int signSize,std::string formatSign);

	/**
	* Validaten document.
	* send the document to server and validate
	*/
	bool viafirmaClient::checkOrignalVSSignedDocument(unsigned char * dataSigned,int dataSize,unsigned char * signInfo,int signSize,std::string formatSign);

	/**
	 * Get the signed data
	 */
	SignedDocument * getSignedDocumentData(std::string idSign) ;

	/**
	 * Get the signed data and info.
	 */
	SignedDocument * getSignedDocument(std::string idSign) ;
private:
	std::string url;
};

